Get Ultrasonic Data
Function:
go.get_ultrasonic_data()
Description: the ultrasonic sensor detects obstacles within its scope (2cm~40cm). The command aims to get data from ultrasonic sensor
Required parameter: null
Return: {front,back,left,right}
front: distance to the obstacle detected by the front ultrasonic sensor; unit: cm
back: distance to the obstacle detected by the back ultrasonic sensor; unit: cm
left: distance to the obstacle detected by the left ultrasonic sensor; unit: cm
right: distance to the obstacle detected by the right ultrasonic sensor; unit: cm
If the return value is 0, it means that the ultrasonic sensor is out of order; if the return value is 40, it means that no obstacle is detected; if the return value is 255, it means that the ultrasonic sensor is not turned on.
Example
result = go.get_ultrasonic_data( ) print (result)Get the detection data of ultrasonic sensor.